<template>
  <div class="main">
    <div class="type">
      <div
        :class="active === 1 ? 'type_active' : ''"
        @click="onActive(1)"
      >首充</div>
      <div
        :class="active === 2 ? 'type_active' : ''"
        @click="onActive(2)"
      >复充</div>
    </div>
    <div class="Recharge">
      <div class="Recharge_top">
        <div class="el-icon-close"></div>
      </div>
      <div class="Recharge_tipe">
        <div style="font-size: 12px; font-weight: 600;">喵币充值</div>
        <div>账户余额：xxx</div>
      </div>
      <div class="Recharge_list">
        <div
          v-for="(item, index) in list"
          :key="index"
          :class="getItemClass(item)"
        >
          <div
            v-if="item.subscript"
            class="item_subscript hidden"
          >{{ item.subscript }}</div>
          <div
            v-if="item.is_recommend === 1"
            class="head"
          >
            <img
              src="../../../assets/head.png"
              alt=""
            >
          </div>
          <div
            v-if="item.product_type == 1"
            class="item_info"
          >
            <div class="item_btn">{{ item.amount }}元</div>

            <div
              v-if="item.free_coin > 0"
              class="item_free_coin"
            >送{{ item.free_coin }}赠币</div>

            <div class="item_coin"> <span class="span_">{{ item.coin }}</span>
              <SvgIcon
                icon-class="species"
                class="iconFont"
              ></SvgIcon>
            </div>
          </div>
          <div
            v-else
            class="item_vip_info"
          >
            <div class="vip_btn vip_in">{{ item.amount }}元</div>
            <div class="item_product_name item_product_name_"> {{ item.product_type === 11 ? `解锁${item.chapter_count ? item.chapter_count : ''}集` : item.product_name }} </div>
            <div class="vip_msg"> {{ getDescription(item) }} </div>
            <!-- <div class="vip_msg"> {{ item.product_type !== 9 ? (item.product_type === 11 ? `${item.amount}元解锁${item.chapter_count ? item.chapter_count : ''}集` : '全场剧集免费观看') : '本剧免费看' }} </div> -->
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import SvgIcon from '@/components/SvgIcon/index.vue'
export default {
  components: {
    SvgIcon
  },
  props: ['row'],
  data() {
    return {
      list: [],
      active: 1
    }
  },
  watch: {
    'row.repeat_list'(newValue, oldValue) {
      if (newValue && this.active === 2) {
        this.list = newValue
      }
    }
  },
  mounted() {
    this.list = this.row.first_list
  },
  methods: {
    onActive(index) {
      if (index === 1) {
        this.list = this.row.first_list
        this.active = 1
      } else {
        this.list = this.row.repeat_list
        this.active = 2
      }
    },
    getItemClass(item) {
      return item.product_type > 1 ? 'vip Recharge_item' : 'Recharge_item'
    },
    getDescription(item) {
      const product_type = Number(item.product_type)
      if (product_type === 1) {
        return `${item.coin}喵币 + ${item.free_coin}赠币`
      } else if ((product_type > 1 && product_type < 9) || product_type == 10) {
        return '全场剧集免费观看'
      } else if (product_type === 9) {
        return item.product_name
      } else if (product_type === 11) {
        return `解锁${item.chapter_count ? item.chapter_count : 0}集(全场可看)`
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@keyframes ball {
  0% {
    transform: rotate3d(0.5, 0.5, 0.5, 25deg);
  }
  50% {
    transform: rotate3d(0, 0, 0, 0);
  }
  100% {
    transform: rotate3d(0.5, 0.5, 0.5, 25deg);
  }
}
.main {
  width: 300px;
  height: 500px;
  position: relative;
  background-color: rgba($color: #000000, $alpha: 1);
  margin: auto;
  border-radius: 18px;
  border: 2px solid #b3b3b3;
  overflow: hidden;
  .type {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    overflow: hidden;
    div {
      background-color: #ffffff;
      width: 60px;
      text-align: center;
      height: 30px;
      line-height: 30px;
      cursor: pointer;
    }
    .type_active {
      background-color: #06c261;
      color: #fff;
    }
  }
  .Recharge {
    width: 300px;
    height: 402px;
    background: #ffffff;
    border-radius: 16rpx 16rpx 0rpx 0rpx;
    position: absolute;
    bottom: 0;
    border-radius: 8px 8px 0 0;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    .Recharge_top {
      height: 40px;
      border-bottom: 2px dashed#eee;
      position: relative;
      flex-shrink: 0;
      .el-icon-close {
        position: absolute;
        right: 10px;
        top: 10px;
        font-size: 16px;
      }
    }
    .Recharge_tipe {
      display: flex;
      justify-content: space-between;
      padding: 10px;
      font-size: 10px;
    }
    .Recharge_list::-webkit-scrollbar {
      display: none;
    }
    .Recharge_list {
      padding: 0 10px;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: flex-start;
      overflow-x: auto;
      .Recharge_item {
        width: 135px;
        height: 86px;
        margin-bottom: 10px;
        border-radius: 9px;
        position: relative;
        background-color: #f5f6fa;
        .item_subscript {
          position: absolute;
          height: 17px;
          background: linear-gradient(133deg, #ff1797 0%, #ff2d44 100%);
          border-radius: 0px 8px 0px 8px;
          padding: 0 5px;
          font-size: 11px;
          max-width: 100%;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #ffffff;
          line-height: 17px;
          right: 0;
        }
        .head {
          width: 30px;
          height: 30px;
          position: absolute;
          bottom: -10px;
          right: 20px;
          animation-name: ball;
          animation-duration: 1s;
          animation-iteration-count: infinite;
          z-index: 10;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .item_info {
          width: 100%;
          height: 100%;
          background: #f6f6f6;
          border-radius: 9px;

          .item_coin {
            width: 100%;
            height: 24px;
            position: absolute;
            bottom: 0;
            background: #fddc76;
            border-radius: 0px 0px 8px 8px;
            font-size: 12px;
            font-family: PingFangSC, PingFang SC;
            font-weight: 500;
            color: #5e4026;
            line-height: 17px;
            display: flex;
            align-items: center;
            justify-content: center;
            > .iconFont {
              font-size: 14px;
              margin-left: 5px;
            }
          }
          .item_btn {
            padding: 18px 0 0 0;
            font-size: 16px;
            font-family: PingFangSC, PingFang SC;
            font-weight: 500;
            color: #e0592b;
            line-height: 18px;
            text-align: center;
          }
          .item_free_coin {
            border-radius: 8px 8px 8px 0px;
            white-space: nowrap;
            font-size: 12px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            padding: 3px 0 0 0;
            text-align: center;
            // transform: scale();
          }
        }
        .item_vip_info {
          .item_product_name {
            font-size: 12px;
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            color: #333333;
            line-height: 18px;
            padding: 3px 0 0 0;
            text-align: center;
          }

          .vip_btn {
            padding: 18px 0 0 0;
            font-size: 16px;
            font-family: PingFangSC, PingFang SC;
            font-weight: 500;
            color: #e0592b;
            line-height: 18px;
            text-align: center;
          }
          .vip_msg {
            width: 100%;
            height: 24px;
            background: rgba(0, 0, 0, 0.65);
            border-radius: 0px 0px 8px 8px;
            position: absolute;
            bottom: 0;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #ffffff;
            line-height: 20px;
            text-align: center;
          }
        }
      }
      .vip {
        background-repeat: no-repeat;
        background-size: 100% 100%;
        -moz-background-size: 100% 100%;
        background-image: url(../../../assets/vip_bacimage_tow.png);
      }
    }
  }
}
</style>